#pragma once

#include <vector>
#include "Config.h"

class LoadCurve
{
public:

	LoadCurve(std::vector<int> points)
		: points(points)
	{
	}

	virtual ~LoadCurve(void)
	{
	}

	float GetValue(int time)
	{
		int ticksPerDay = 60 * 60 * 24 / Config::SecPerTick;
		int dt = ticksPerDay / (points.size() - 1);
		time = time % ticksPerDay;

		int i = time / dt;
		int j = i+1;

		float value = 0;

		if(j < points.size())
		{
			float p = (float)(time % dt) / dt;
			int a = points[i];
			int b = points[j];

			value = (b - a) * p + a;
		}
		else
		{
			value = points.back();
		}


		return value;
	}

private:
	std::vector<int> points;

};

